﻿using SQLite;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Dt261.Model
{
    enum PointDraw
    {
        POINT_TYPE_0 = 0,
        POINT_TYPE_1 = 1,
        POINT_TYPE_2,
        POINT_TYPE_3,
        POINT_TYPE_4,
        POINT_TYPE_5,
        POINT_TYPE_6,
        POINT_TYPE_7,
        POINT_TYPE_8,
        POINT_TYPE_9,
        POINT_TYPE_10,
        POINT_TYPE_11,
        POINT_TYPE_12,
        POINT_TYPE_13,
        POINT_TYPE_14,
        POINT_TYPE_15,
        POINT_TYPE_16,
        POINT_TYPE_17,
        POINT_TYPE_18,
        POINT_TYPE_19,

    }

    [Table("DisPlayOption")]
    class DisPlayOption
    {
        private Boolean isDifAcMasked;//气导状态下，有掩蔽音和无掩蔽音的标记是否不同
        private Boolean isLinkAc;//气导状态下，是否用线连接每个点
        private Boolean isDifBcRight;//骨导状态下，左耳和右耳标记是否不同
        private Boolean isLinkBc;//骨导状态下，是否用线连接每个点

        private int acRightType;//气导 右耳 无掩蔽 标记
        private int acRightMaskedType;//气导 右耳 加掩蔽 标记
        private int acLeftType;//气导 左耳 无掩蔽 标记
        private int acLeftMaskedType;//气导 左耳 加掩蔽 标记

        private int bcRightType;//骨导 右耳 无掩蔽 标记
        private int bcRightMaskedType;//骨导 右耳 加掩蔽 标记
        private int bcLeftType;//骨导 左耳 无掩蔽 标记
        private int bcLeftMaskedType;//骨导 左耳 加掩蔽 标记

        private int uclPointType;//痛域标记点的类型
        private string userId;
        private int id;
        private string uid;

        public DisPlayOption()
        {
            isDifAcMasked = true;
            isLinkAc = true;
            isDifBcRight = true;
            isLinkBc = false;

            acRightType = (int) PointDraw.POINT_TYPE_1;
            acRightMaskedType = (int)PointDraw.POINT_TYPE_10;
            acLeftType = (int)PointDraw.POINT_TYPE_2;
            acLeftMaskedType = (int)PointDraw.POINT_TYPE_9;

            bcRightType = (int)PointDraw.POINT_TYPE_4;
            bcRightMaskedType = (int)PointDraw.POINT_TYPE_7;
            bcLeftType = (int)PointDraw.POINT_TYPE_3;
            bcLeftMaskedType = (int)PointDraw.POINT_TYPE_8;

            uclPointType = (int)PointDraw.POINT_TYPE_16;

            uid = System.Guid.NewGuid().ToString("N");

            userId = GlobalData.LoginUser.Uid;
        }

        public Boolean IsDifAcMasked { get => this.isDifAcMasked; set
            {
                this.isDifAcMasked = value;
          
                if (value)
                {
                    acRightType = (int)PointDraw.POINT_TYPE_1;
                    acRightMaskedType = (int)PointDraw.POINT_TYPE_10;
                    acLeftType = (int)PointDraw.POINT_TYPE_2;
                    acLeftMaskedType = (int)PointDraw.POINT_TYPE_9;
                }
                else
                {
                    acRightType = (int)PointDraw.POINT_TYPE_1;
                    acRightMaskedType = acRightType;
                    acLeftType = (int)PointDraw.POINT_TYPE_2;
                    acLeftMaskedType = acLeftType;
                }
            }
        }
        public Boolean IsLinkAc { get => this.isLinkAc; set => this.isLinkAc = value; }
        public Boolean IsDifBcRight { get => this.isDifBcRight; set
            {
                this.isDifBcRight = value;
                if (value)
                {
                    if (bcRightType != (int)PointDraw.POINT_TYPE_3 && bcRightType != (int)PointDraw.POINT_TYPE_4)
                    {
                        BcRightType = (int)PointDraw.POINT_TYPE_3;
                    }
                }
                else
                {
                    if (bcRightType != (int)PointDraw.POINT_TYPE_13 && bcRightType != (int)PointDraw.POINT_TYPE_10)
                    {
                        BcRightType= (int)PointDraw.POINT_TYPE_13;
                    }
                }
            }
        }
        public Boolean IsLinkBc { get => this.isLinkBc; set => this.isLinkBc = value; }
        public int AcRightType { get => acRightType; set => acRightType = value; }
        public int AcRightMaskedType { get => acRightMaskedType; set => acRightMaskedType = value; }
        public int AcLeftType { get => acLeftType; set => acLeftType = value; }
        public int AcLeftMaskedType { get => acLeftMaskedType; set => acLeftMaskedType = value; }
        public int BcRightType { get => bcRightType; set
            {
                bcRightType = value;
                if (isDifBcRight)
                {
                    if (value == (int)PointDraw.POINT_TYPE_3)
                    {
                        bcLeftType = (int)PointDraw.POINT_TYPE_4;
                    }
                    else
                    {
                        bcLeftType = (int)PointDraw.POINT_TYPE_3;
                    }
                }
                else
                {
                    bcLeftType = value;
                }

                if (value == (int)PointDraw.POINT_TYPE_3)
                {
                    if (bcRightMaskedType != (int)PointDraw.POINT_TYPE_8 && bcRightMaskedType != (int)PointDraw.POINT_TYPE_6)
                    {
                        BcRightMaskedType = (int)PointDraw.POINT_TYPE_8;
                    }
                }
                else
                {
                    if (bcRightMaskedType != (int)PointDraw.POINT_TYPE_7 && bcRightMaskedType != (int)PointDraw.POINT_TYPE_5)
                    {
                        BcRightMaskedType = (int)PointDraw.POINT_TYPE_7;
                    }
                }
            } }
        public int BcRightMaskedType { get => bcRightMaskedType; set
            {
                bcRightMaskedType = value;
            
                if (value == (int)PointDraw.POINT_TYPE_7)
                {
                    bcLeftMaskedType = (int)PointDraw.POINT_TYPE_8;
                }
                else if (value == (int)PointDraw.POINT_TYPE_8)
                {
                    bcLeftMaskedType = (int)PointDraw.POINT_TYPE_7;
                }
                else if (value == (int)PointDraw.POINT_TYPE_5)
                {
                    bcLeftMaskedType = (int)PointDraw.POINT_TYPE_6;
                }
                else 
                {
                    bcLeftMaskedType = (int)PointDraw.POINT_TYPE_5;
                }
            } }
        public int BcLeftType { get => bcLeftType; set => bcLeftType = value; }
        public int BcLeftMaskedType { get => bcLeftMaskedType; set => bcLeftMaskedType = value; }
        public int UclPointType { get => uclPointType; set => uclPointType = value; }
        public string UserId { get => userId; set => userId = value; }

        [PrimaryKey, AutoIncrement]
        public int Id { get => id; set => id = value; }
        public string Uid { get => uid; set => uid = value; }
    }
}
